package com.hilinos.base.common.init;

import com.hilinos.common.util.RandomUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class ServerInit implements ApplicationRunner {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        String key = RandomUtils.genRandomStr(24);
        redisTemplate.opsForValue().set(key, RandomUtils.genRandomStr(24));
        redisTemplate.delete(key);
        log.info("redis初始化成功");
    }

}
